package bio.client;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Date;

public class BIOClient1 {
    public static void main(String[] args) {
        try {
            Socket socket = new Socket("127.0.0.1", 16101);
            OutputStream outputStream = socket.getOutputStream();
            Date date = new Date(System.currentTimeMillis());
            outputStream.write((date + "Hello I`m Client1 \r\n").getBytes());
            outputStream.flush();
            Thread.sleep(7000);
            socket.shutdownOutput();

            BufferedReader inputStream = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            String str;
            while ((str = inputStream.readLine()) != null) {
                System.out.println(str);
            }

            socket.close();

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
